package com.qny.ai.test;

import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;

public class CalculateHash {
    public static void main(String[] args) {
        String password = "123456";
        String salt = "qiniu_ai_platform_2024";
        String combined = password + salt;
        
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            byte[] hashedPassword = md.digest(combined.getBytes(StandardCharsets.UTF_8));
            
            StringBuilder sb = new StringBuilder();
            for (byte b : hashedPassword) {
                sb.append(String.format("%02x", b));
            }
            
            String hash = sb.toString();
            System.out.println("密码: " + password);
            System.out.println("哈希: " + hash);
            
            // 生成SQL
            System.out.println("\nSQL插入语句：");
            System.out.println("INSERT INTO `app_user` (`username`, `password`, `email`, `preferred_language`) VALUES");
            System.out.println("('admin', '" + hash + "', 'admin@example.com', 'zh'),");
            System.out.println("('test', '" + hash + "', 'test@example.com', 'zh'),");
            System.out.println("('user1', '" + hash + "', 'user1@example.com', 'zh');");
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
